let express = require('express');
let mysql = require('./db')

let router = express.Router()

router.get('/list', (req, res) => {
    let { page=1, limit=5 } = req.query;
    let index = (page - 1) * limit;
    mysql.query(`select * from swiper limit ${index},${limit};`, function (state, data) {
        if (state) {
            res.send({
                code: 200,
                msg: 'success',
                data
            })
        } else {
            res.send({
                code: 400,
                msg: 'error',
                data
            })
        }
    })
})

router.get('/list2', (req, res) => {
    let { page=1, limit=5 } = req.query;
    let index = (page - 1) * limit;
    mysql.query(`select * from swiper2 limit ${index},${limit};`, function (state, data) {
        if (state) {
            res.send({
                code: 200,
                msg: 'success',
                data
            })
        } else {
            res.send({
                code: 400,
                msg: 'error',
                data
            })
        }
    })
})

module.exports = router